<?php
require $_SERVER['DOCUMENT_ROOT'].'/../_core/common.php';

$msg = array();

//权限验证
if( Role::init() == false ){
	$msg['error'] = false;
	$msg['string'] = '权限不足！';
	$myjson = json_encode($msg); 
	echo $myjson; 
	exit;
}

$db = new DB('news');

$id = isset($_POST['id']) ? intval($_POST['id']) : 0;

$sql = 'select id,title from relative_news where id='.$id.' and is_del=1 limit 1';
$rs = $db->query($sql)->getOne();
	
if( $rs['id'] < 1 ){//id不存在
	$msg['string'] = '参数有误！';
}else{
	//更新is_del字段
	$data=array('is_del'=>2,'updated'=>time());
	$db->table('relative_news')->where('id='.$id)->update($data)->run();
	
	//记录动作日志
	Log::logs_articles(-2, 4, $rs['id'], $rs['title']);

	$msg['string'] = '推荐文章《'.$rs['title'].'》已删除!';
}

$myjson = json_encode($msg); 
echo $myjson; 
exit;